package net.siufung.boot.datasource.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.siufung.core.model.EnumsVo;
import net.siufung.core.model.IEnum;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 陈建峰
 * @since 2022/9/5 3:53 下午
 */
@AllArgsConstructor
public enum FieldEmptyValues implements IEnum<Boolean> {

    /**
     * YES
     */
    IS(Boolean.TRUE, "YES"),
    /**
     * NO
     */
    NO(Boolean.FALSE, "NO");

    @Getter
    @Setter
    private Boolean value;

    @Getter
    @Setter
    private String desc;

    public static FieldEmptyValues get(Boolean value) {
        return IEnum.get(FieldEmptyValues.class,
                enums -> enums.getValue().equals(value));
    }

    public static List<EnumsVo> getList(){
        return IEnum.findList(FieldEmptyValues.class).stream()
                .map(element -> new EnumsVo(element.getValue(), element.getDesc()))
                .collect(Collectors.toList());
    }
}
